// author by welong
// zuowl@qq.com
// 2014-09-04  20:08
// PAT basic 1016

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int count_c(char *str, char c)		//cal how many char c in string str, return count
{
	unsigned i;
	int count = 0;

	for(i = 0; i < strlen(str); i++)
		if(str[i] == c)
			count++;

	return count;
}

void malloc_equ(char *A, char **B, int lena, int lenb)	//make string equal size
{
	int i;
	char *B_bak = *B;

	*B = (char*)malloc(lena + 1);

	for(i = 0; i < lena; i++)
		(*B)[i] = i < lenb ? B_bak[i] : '0';

	(*B)[i] = 0;
}

char* str_add(char *A, char *B)		//cal the result of string A add string B, result the result(need to free, after used)
{
	int  i, mark, itemp, lena, lenb;//mark , carry flag; output reverse store the normal result
	char *output, *ctemp;

	lena = strlen(A);
	lenb = strlen(B);

	if(lena < lenb)
	{
		ctemp = A; A = B; B = ctemp;
		itemp = lena; lena = lenb; lenb = itemp;
	}
	
	if(lena != 0)
		output = (char*)malloc(lena + 1);
	else
	{
		output = (char*)malloc(2);
		output[0] ='0';
		output[1] = 0;
		return output;
	}

	if(lena > lenb)
		malloc_equ(A, &B, lena, lenb);

	for(i = 0, mark = 0; i < lena; i++)
	{
		output[i] = A[i] - '0' + B[i] + mark;
		mark = 0;

		if(output[i] - '0' >= 10)
		{
			mark++;
			output[i] -= 10;
		}
	}

	if(mark > 0)
		output[i++] = mark + '0';

	output[i] = 0;
	return output;
}

int main(int argc, char **argv)
{
	int  count_da = 0, count_db = 0;
	char A[20], B[20], Da, Db;
	int  i, lenop;
	char *output;

//while(1){
	scanf("%s %c %s %c", A, &Da, B, &Db);
	
	count_da = count_c(A, Da);
	count_db = count_c(B, Db);

	memset(A, 0, 10);	memset(A, Da, count_da);
	memset(B, 0, 10);	memset(B, Db, count_db);

	//printf("A:%s\n", A);
	//printf("B:%s\n", B);

	output = str_add(A, B);
	lenop  = strlen(output);

	for(i = lenop - 1; i >= 0; i--)		//if printf this string will appearent like 0009, cause test site 3 error
	{
		if(output[i] == '0' && i != 0)
			continue;

		printf("%c", output[i]);
	}
	printf("\n");
//}
	return 0;
}